
package com.shop.cloud.common.portal.config;

import com.shop.cloud.common.portal.constant.PortalConstants;
import com.shop.cloud.common.portal.interceptor.ThirdSessionInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *
 * web配置
 */
@Configuration
@AllArgsConstructor
public class WebConfig implements WebMvcConfigurer {
	private final RedisTemplate redisTemplate;

	/**
	 * 拦截器
	 * @param registry
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		/**
		 * 进入ThirdSession拦截器
		 */
		registry.addInterceptor(new ThirdSessionInterceptor(redisTemplate))
				//放行接口
				.excludePathPatterns("/static/**",
						"/v3/api-docs/**",
						"/swagger-ui/**",//swagger
						"/wxuser/loginma",//小程序登录
						"/wxuser/loginmp",//公众号h5登录
						"/h5portaldomain/*",//获取H5前端域名
						PortalConstants.ORDER_NOTIFY_URL_WX+"/*",//订单支付回调
						PortalConstants.ORDER_NOTIFY_URL_ALI+"/*",//订单支付回调
						PortalConstants.RECHARGE_NOTIFY_URL_WX+"/*",//余额充值回调
						PortalConstants.RECHARGE_NOTIFY_URL_ALI+"/*",//余额充值回调
						PortalConstants.ORDER_LOGISTICSR_NOTIFY_URL,//订单物流回调
						PortalConstants.ORDER_REFUNDS_NOTIFY_URL+"/*",//订单退款回调
						PortalConstants.VIPUSERRECHARGE_NOTIFY_URL_WX+"/*",//会员充值支付回调
						PortalConstants.VIPUSERRECHARGE_NOTIFY_URL_ALI+"/*");
	}
}
